



#include <brpc/naming_service.h>
#include <gflags/gflags.h>
#include <memory>
#include "compile-server.h"
#include "brpc.h"
#include "etcd_path.h"

DEFINE_int32(start_port, 38083, "start port");

//brpc 
DEFINE_string(value,"127.0.0.1:38083","value of register file_storage to etcd");
//etcd
DEFINE_string(etcd_host, "127.0.0.1:2379", "etcd addr");

// docker
DEFINE_string(image_name, "oj_docker_image", "docker image name");
DEFINE_string(relationship, "./app:/app", "directry relation");
DEFINE_string(dockerfile_path, "./", "dockerfile of create docker image ");
DEFINE_string(docker_work_path, "./app/", "docker work path");


int main(){
    lyt::EtcdNamingService name_server;
    brpc::NamingServiceExtension()->RegisterOrDie("etcd", &name_server);
    
    lyt::CompileServer::ptr svr = lyt::CompileServerBuild()
        .make_compile_service(
            FLAGS_image_name,
            FLAGS_relationship,
            FLAGS_dockerfile_path,
            FLAGS_docker_work_path
        )
        .make_brpc_server(FLAGS_start_port)
        .make_register(FLAGS_etcd_host,FLAGS_value)
        .build();
    svr->start();
    return 0;
}